home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d13 / pj9_3.arc / TOKEN.C < prev    next >
C/C++ Source or Header  |  1991-10-07  |  1KB  |  42 lines

  1. /* 
  2.  *    Source Code Illustrating Use of VM Calls 
  3.  *    by Stephen Kuhn (The Iliad Group)
  4.  */
  5.  
  6. typedef    unsigned long    TOKEN;
  7.  
  8. typedef TOKEN            TOKLINE;
  9. typedef TOKLINE            STRING;
  10. typedef struct strline    STRLINE;
  11.  
  12. struct strline    {
  13.     TOKLINE    next;            /* token of next line in chain */
  14.     TOKLINE    prev;            /* token of prev line in chain */
  15.     STRING    text;            /* token of text for this line */
  16. };
  17.  
  18. #define        lineref(linetok)        ((STRLINE *)vmderef(linetok))
  19. #define        stringref(stringtok)    ((char *)vmderef(stringtok))
  20. #define        TOKLINE0            ((TOKLINE)0)
  21. #define        STRING0            ((STRING)0)
  22.  
  23. /* This function takes a head line token and a tail line token and
  24.    scans the lines between head and tail (inclusive) for a line that
  25.    begins with a number sign "#".
  26.  
  27.    Returns the token of the line if found, TOKLINE0 if not found.
  28. */
  29.  
  30. TOKLINE    linescan(headtok, tailtok)
  31.  
  32. {
  33.     TOKLINE    line;
  34.  
  35.     for    (line=headtok; line != TOKLINE0; line=lineref(line)->next)
  36.     {
  37.         if    (*stringref(lineref(line)->text) == '#')
  38.             return(line);
  39.     }
  40.     return(TOKLINE0);
  41. }
  42.